'use strict';
const compress = require('koa-compress');
const logger = require('koa-logger');
const serve = require('koa-static');
const route = require('koa-route');
const koa = require('koa');
const path = require('path');
const views = require('co-views');
const app = module.exports = koa();

// Logger
app.use(logger());

// Serve static files
app.use(serve(path.join(__dirname, 'public')));

const render=views(__dirname + '/views', {
  map: { html: 'swig' }
});

app.use(route.get('/',function*() {
  this.body = yield render('layout', { 'title': '我是首页','initScript':'/dist/bundle.js' });
}));

// Compress
app.use(compress());

if (!module.parent) {
  app.listen(3000);
  console.log('listening on port 3000');
}
